package com.example.designer.iter;

import com.example.designer.iter.inte.Menu;
import com.example.designer.iter.pojo.Foot;

import java.util.Iterator;

/**
 * 服务员进行菜单打印
 */
public class Waiter {
    Menu listMenu;
    Menu arrayMenu;

    public Waiter(Menu listMenu, Menu arrayMenu) {
        this.listMenu = listMenu;
        this.arrayMenu = arrayMenu;
    }

    //打印菜单
    public void print(){
        Iterator<Foot> list = listMenu.createIterator();
        Iterator<Foot> array = arrayMenu.createIterator();

        System.out.println("list菜单 : ");
        print(list);
        System.out.println("array菜单 : ");
        print(array);
    }

    public void print(Iterator iterator){
        while (iterator.hasNext()){
            Foot next = (Foot) iterator.next();
            System.out.println(next.getName() + "==" + next.getPrice());
        }
    }
}
